/*
 * usb_printf.h
 *
 *  Created on: Apr 4, 2013
 *      Author: r.leonov
 */

#ifndef USB_PRINTF_H_
#define USB_PRINTF_H_

#include <string.h>

#define BUF_SIZE  64

class CircBuf_t {
private:
    uint8_t Buf[BUF_SIZE];
    uint8_t *PW, *PR;
    uint32_t fcnt;
public:
    void Init() { fcnt = 0; PW = Buf; PR = Buf; }
    void Write(uint8_t *PBuf, uint32_t Alength);
    void WriteByte(uint8_t A);
    bool Read(uint8_t *PBuf, uint32_t *PLength);
    uint32_t GetFullCnt(void) { return  fcnt;}
    uint32_t GerFreeCnt(void) { return (BUF_SIZE - fcnt);}
};

class UsbCmd_t {
private:
    CircBuf_t BufToHost;
    uint32_t Count;
public:
    CircBuf_t BufToDevice;
    void Printf(const char *S, ...);
    void Init();
    void Task();
};

extern UsbCmd_t UsbCmd;
#endif /* USB_PRINTF_H_ */
